<%@ page language="java" pageEncoding="UTF-8" buffer="64kb" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/pages/safeai/jsp/common/taglibs.jsp"%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>降价通知</title>

<link href="${ctx}/style/style.css" rel="stylesheet" type="text/css" />
<script type='text/javascript' src='${ctx}/js/Ajax.js'></script>
<script type='text/javascript' src='${ctx}/dwr/engine.js'></script>
<script type='text/javascript' src='${ctx}/dwr/util.js'></script>
</head>

<body>
<div class="invoice">
<ul>
<form action="${ctx}/price/pricenotifyMessage.do" method="post">
<li class="Notify" style="padding-left:15px;width:360px;">降价通知</li>
<input type="hidden" id="productID" name="productId" value="${product.id}">
<input type="hidden" name="method" value="insert">
<li>联系电话：   <label><input type="text" id="phoneId" name="phone" /  class="invoice_input"></label></li>
<li>　E-mail： 
  <label><input type="text" value="${USERINFOFRONT.email}" id="emailId" name="email" /  class="invoice_input"></label></li>
  <li style="padding-left:65px;width:300px">请填写有效的E-mail地址，以便我们及时通知您</li>
<li ><span style="width:65px;float:left">商品名称：</span><span  style="width:300px;float:left;color:#FF9900">${product.name}</span></li>
  <li ><span style="width:65px;float:left">当前价格：</span><span  style="width:300px;float:left;color:#FF9900">${product.price}元</span></li>
	<input type="hidden" id="nowPriceId" name="nowPrice" value="${product.price}">  
  <li >期望价格：<label> 
    <input type="text" id="hopePriceId" name="hopePrice" /  class="invoice_input"></label></li>
  <li><span style="width:65px;float:left">　　附言：</span><span style="width:300px;float:left"> <label>
<textarea id="commentId" name="comment"/style="width:300px;height:150px;"></textarea>
</label></span></li>
<li style="margin-top:20px; height:30px;text-align:center"><a href="#" onclick="insert()" class="reg_button" target="_self">提交相关信息</a>　<a href="#" onclick="window.close();" class="reg_button2 ">关闭此页面</a></li>
</form>
</ul>
</div>
</body>
</html>

<script language="javascript" type="text/javascript">
	function insert(){
        var ajax = new Ajax();
        var productID=document.getElementById("productID").value;
		var phoneId=document.getElementById("phoneId").value;
		var emailId=document.getElementById("emailId").value;
		var nowPriceId=document.getElementById("nowPriceId").value;
		var hopePriceId=document.getElementById("hopePriceId").value;
		
		/*
		var patternss = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
      	var ss = /^(?:13\d|15\d|18\d)-?\d{5}(\d{3}|\*{3})$/;
      	if (!(ss.test(hopePriceId))){
      		if(!patternss.exec(hopePriceId)){
      			alert('请输入正确的固定电话,如010-63458858或010-63458858-025或者正确的手机号码,如13501284888或15811445345');
      			return;
      		}
        }
        
       if(isNaN(phoneId)){
			alert("请输入正确的固定电话,如010-63458858或010-63458858-025或者正确的手机号码,如13501284888或15811445345");
			alert("2");
			return false;
		}
        
		*/
		
		
		if(phoneId.search(/^((\(\d{3}\))|(\d{3}\-))?13[0-9]\d{8}|15[89]\d{8}/) == -1&&phoneId.search(/^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/) == -1){
			alert("请输入正确的固定电话,如010-63458858或010-63458858-025或者正确的手机号码,如13501284888或15811445345");
			return false;
		}
		
		if(isNaN(hopePriceId)){
    		alert('你输入的数据不是数字!');
 		}else if(hopePriceId<0){
    		alert("请不要数据负数!");
 		}else{
	    var commentId=document.getElementById("commentId").value;  
        var para = "&productId="+productID+"&nowPrice="+nowPriceId+"&hopePrice="+hopePriceId+"&email="+emailId+"&phone="+phoneId+"&comment="+encodeURI(commentId);
        ajax.ajaxRequest("${ctx}/price/pricenotifyMessage.do","method=insert"+para,"get",insertBack);
        }
    }
    
    function insertBack(str){
        if(str==0){
        	alert('添加失败!');
			return;
		}else{
			alert('添加成功!');
			window.close();
		}
    }
</script>